package com.lakeworks.service.impl;


import com.lakeworks.domain.SysWechatUser;
import com.lakeworks.mapper.SysWechatUserMapper;
import com.lakeworks.service.ISysWechatUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 微信用户Service业务层处理
 *
 * @author lake
 * @date 2023-02-20
 */
@Service
public class SysWechatUserServiceImpl implements ISysWechatUserService {
    @Autowired
    private SysWechatUserMapper sysWechatUserMapper;

    /**
     * 查询微信用户
     *
     * @param id 微信用户主键
     * @return 微信用户
     */
    @Override
    public SysWechatUser selectSysWechatUserById(Long id) {
        return sysWechatUserMapper.selectSysWechatUserById(id);
    }

    /**
     * 查询微信用户列表
     *
     * @param sysWechatUser 微信用户
     * @return 微信用户
     */
    @Override
    public List<SysWechatUser> selectSysWechatUserList(SysWechatUser sysWechatUser) {
        return sysWechatUserMapper.selectSysWechatUserList(sysWechatUser);
    }

    /**
     * 新增微信用户
     *
     * @param sysWechatUser 微信用户
     * @return 结果
     */
    @Override
    public int insertSysWechatUser(SysWechatUser sysWechatUser) {
        int i = sysWechatUserMapper.insertSysWechatUser(sysWechatUser);
        if (i == 0)
            throw new RuntimeException("wechatUser save error!");
        return i;
    }

    /**
     * 修改微信用户
     *
     * @param sysWechatUser 微信用户
     * @return 结果
     */
    @Override
    public int updateSysWechatUser(SysWechatUser sysWechatUser) {
        return sysWechatUserMapper.updateSysWechatUser(sysWechatUser);
    }

    /**
     * 批量删除微信用户
     *
     * @param ids 需要删除的微信用户主键
     * @return 结果
     */
    @Override
    public int deleteSysWechatUserByIds(Long[] ids) {
        return sysWechatUserMapper.deleteSysWechatUserByIds(ids);
    }

    @Override
    public SysWechatUser selectByOpenId(String openId) {
        return sysWechatUserMapper.queryByOpenId(openId);
    }
}
